Exp=M
ModuleFileName=SoftKey.cs
@end
                                        
//´칤Զɣѡģ顱
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

	/// <summary>
	/// </summary>
	public class softkey
	{
		[DllImport ("My3l_ex.dll")]
		public static extern  int FindPort_3(string filename,int start, StringBuilder OutKeyPath);
		[DllImport ("My3l_ex.dll")]
        public static extern int FindPort_4(string filename, int start, string HKey, string LKey, StringBuilder OutKeyPath);
		[DllImport ("My3l_ex.dll")]
		public static extern  int Cal_2(string filename,int start, int pos,ref short a,ref short b,ref short c,ref short d, string KeyPath_2,int cycle);
		[DllImport ("My3l_ex.dll")]
        public static extern int CalculateEx_3(string filename, int start, int pos, ref short a, ref short b, ref short c, ref short d, string KeyPath_2, int cycle);
		[DllImport ("My3l_ex.dll")]
        public static extern int E_Ex_3(string HKey, string LKey, string filename, string filename_lll, string KeyPath_2);
		[DllImport ("My3l_ex.dll")]
        public static extern int GetIDVersionEx(ref int ID, ref short version, string KeyPah);
		[DllImport ("My3l_ex.dll")]
        public static extern int YReadEx(int Address, ref byte OutData, string KeyPah);
		[DllImport ("My3l_ex.dll")]
        public static extern int YWriteEx(byte OutData, int Address, string KeyPah);
		[DllImport ("My3l_ex.dll")]
        public static extern int ReadString([In, Out]byte[] OutString, int Address, int vlen, string KeyPah);
		[DllImport ("My3l_ex.dll")]
		public static extern  int FindPort(int start, StringBuilder OutKeyPath);
		[DllImport ("My3l_ex.dll")]
        public static extern int WriteString(string OutString, int Address, string KeyPah);
		[DllImport ("My3l_ex.dll")]
        public static extern int E_Dec_6(string HKey, string LKey, byte[] array_ele2, [In, Out] byte[] out_array, string KeyPah);
        [DllImport("My3l_ex.dll")]
        public static extern int CalculateEx_2(byte[] array_ele, ref short a, ref short b, ref short c, ref short d, string KeyPath_2, int mylen, int cycle);
   

		private static int LastError;
		private static string KeyPath ;
        private string E_Hkey, E_Lkey;
		public softkey()
		{
			LastError = 0; //ʼΪ޴
		}
		
		//YGetLastError
		//ĿģȡĴ룬Ϊ0ʾûд
		//ؽĴ
		public  int YGetLastError()
		{
			return LastError;
		}

        //ȡָеȨ
        public bool F_ReadKey() 
        {
        byte OutData=0 ;E_Hkey ="";E_Lkey ="";
        int n ;
        for(n=0;n<4;n++)
        {
          if( YReadEx(n, ref OutData, KeyPath) != 0 ) return false;
            E_Hkey = OutData.ToString("X2") + E_Hkey;
        }
        for(n=4;n<8;n++)
        {
          if (YReadEx(n, ref OutData, KeyPath) !=0) return false;
            E_Lkey = OutData.ToString("X2") + E_Lkey;
        }
        return true;
        }
		#INI#
		#Ini_2#
		#Ystrcat#
		#YCompareString#
		#Ystrcpy#
		#YAdd#
		#YSetValue#
		#YDivide#
		#Ymultiply#
		#YDecrease#
		#compare#
		#CheckKey#
		#Yor#
		#YAnd#	
		
	}

